﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PersonalHoldings.ascx.cs"
    Inherits="TCKQKL.FrontEnd.Web.Controls.PersonalHoldings" %>
<%@ Register Src="StockAccount.ascx" TagName="StockAccount" TagPrefix="uc1" %>
<link href="../styles/data.css" rel="stylesheet" type="text/css" />
<%@ Import Namespace="TCKQKL.FrontEnd.DataModel" %>
<%@ Import Namespace="TCKQKL.FrontEnd.Config" %>
<% if (personal != null)
   {%>
<table class="data">
    <% if (personal.MainAccount != null)
           if (personal.MainAccount.Holding.Count > 0)
           {%>
    <tr>
        <td class="OrderAlertMessageStyle" colspan="9">
            <img src="./Images/money.gif" width="40" height="40" alt="money" /><%=personal.MainAccount.AccountProfile.name + " (" + personal.MainAccount.AccountProfile.accountNo + ")"%>
        </td>
    </tr>
    <tr>
        <th class="InnerHeading">
            MCK
        </th>
        <th class="InnerHeading">
            KLGD
        </th>
        <th class="InnerHeading">
            KL chờ về
        </th>
        <th class="InnerHeading">
            KL đã bán
        </th>
        <th class="InnerHeading">
            KL phong tỏa
        </th>
        <th class="InnerHeading">
            Mua TB
        </th>
        <th class="InnerHeading">
            Tham chiếu
        </th>
        <th class="InnerHeading">
            Thay đổi
        </th>
        <th class="InnerHeading">
            Lãi tạm tính
        </th>
    </tr>
    <%for (int i = 0; i < personal.MainAccount.Holding.Count; i++)
      { %>
    <tr>
        <td class="InnerData">
            <div style="font-weight: bold;" title="<%=personal.MainAccount.Holding[i].Quotes.CompanyName%>">
                <%=personal.MainAccount.Holding[i].Quotes.Symbol%></div>
        </td>
        <td class="InnerData">
            <%=personal.MainAccount.Holding[i].Account.tradingAmount.ToString("N0")%>
        </td>
        <td class="InnerData">
            <%=personal.MainAccount.Holding[i].Account.nettingAmount.ToString("N0")%>
        </td>
        <td class="InnerData">
            <%=personal.MainAccount.Holding[i].Account.lockedAmount.ToString("N0")%>
        </td>
        <td class="InnerData">
            <%=personal.MainAccount.Holding[i].Account.trustedAmount.ToString("N0")%>
        </td>
        <td class="InnerData" style="text-align: right">
            <%=personal.MainAccount.Holding[i].AverageBought.ToString("N")%>
        </td>
        <td class="InnerData">
            <%=personal.MainAccount.Holding[i].Quotes.Closed %>
        </td>
        <td class="InnerData">
            <%=((personal.MainAccount.Holding[i].Quotes.Closed - personal.MainAccount.Holding[i].AverageBought) < 0) ? 
                "<span style=\"color: red;\">" + String.Format("{0:n}", personal.MainAccount.Holding[i].Quotes.Closed - personal.MainAccount.Holding[i].AverageBought) + "▼" + String.Format("{0:n}", (personal.MainAccount.Holding[i].Quotes.Closed - personal.MainAccount.Holding[i].AverageBought) * 100 / (personal.MainAccount.Holding[i].AverageBought)) + "%</span>" : 
                personal.MainAccount.Holding[i].AverageBought.Equals(0)?
                            "<span style=\"color: green;\">0▲0</span>":
                            "<span style=\"color: green;\">" + String.Format("{0:n}", personal.MainAccount.Holding[i].Quotes.Closed - personal.MainAccount.Holding[i].AverageBought) + "▲" + String.Format("{0:n}", (personal.MainAccount.Holding[i].Quotes.Closed - personal.MainAccount.Holding[i].AverageBought) * 100 / (personal.MainAccount.Holding[i].AverageBought))  + "%</span>"%>
        </td>
        <td class="InnerData">
            <%=((personal.MainAccount.Holding[i].Quotes.Closed - personal.MainAccount.Holding[i].AverageBought) < 0) ? "<span style=\"color: red;\">" + String.Format("{0:0,0}", (personal.MainAccount.Holding[i].Quotes.Closed - personal.MainAccount.Holding[i].AverageBought) * (personal.MainAccount.Holding[i].Account.tradingAmount + personal.MainAccount.Holding[i].Account.nettingAmount)*1000) + "▼</span>" : "<span style=\"color: green;\">" + String.Format("{0:0,0}", (personal.MainAccount.Holding[i].Quotes.Closed - personal.MainAccount.Holding[i].AverageBought) * (personal.MainAccount.Holding[i].Account.tradingAmount + personal.MainAccount.Holding[i].Account.nettingAmount)*1000) + "▲</span>"%>
        </td>
    </tr>
    <%}%>
    <tr>
        <th class="InnerData">
            Giá trị:
        </th>
        <th class="InnerData">
            <%=personal.MainAccount.TradingValue.ToString("N0")%>
        </th>
        <th class="InnerData">
            <%=personal.MainAccount.NettingValue.ToString("N0")%>
        </th>
        <th class="InnerData">
            <%=personal.MainAccount.LockedValue.ToString("N0")%>
        </th>
        <th class="InnerData">
            &nbsp;
        </th>
        <th class="InnerData" colspan="2">
            Tổng giá trị:
            <%=(personal.MainAccount.TotalValue + personal.MainAccount.NettingValue < 0) ? "<span style=\"color: red;\">" + String.Format("{0:0,0}", personal.MainAccount.TradingValue + personal.MainAccount.NettingValue) + "</span>" : "<span style=\"color: green;\">" + String.Format("{0:0,0}", personal.MainAccount.TradingValue + personal.MainAccount.NettingValue) + "</span>"%>
        </th>
        <th class="InnerData" colspan="2">
        </th>
    </tr>
    <%}%>
</table>
<br />
<%}%>
<% if (personal.AssignAccounts != null)
       if (personal.AssignAccounts.Count > 0)
           for (int x = 0; x < personal.AssignAccounts.Count; x++)
           {%>
<br />
<table class="data">
    <tr>
        <td class="Master" colspan="9">
            <%=personal.AssignAccounts[x].AccountProfile.name + " (" + personal.AssignAccounts[x].AccountProfile.accountNo + ")"%>
        </td>
    </tr>
    <% if (personal.AssignAccounts[x] != null)
           if (personal.AssignAccounts[x].Holding.Count > 0)
           {%>
    <tr>
        <th class="InnerHeading">
            MCK
        </th>
        <th class="InnerHeading">
            KLGD
        </th>
        <th class="InnerHeading">
            KL chờ về
        </th>
        <th class="InnerHeading">
            KL đã bán
        </th>
        <th class="InnerHeading">
            KL phong tỏa
        </th>
        <th class="InnerHeading">
            Mua TB
        </th>
        <th class="InnerHeading">
            Tham chiếu
        </th>
        <th class="InnerHeading">
            Thay đổi
        </th>
        <th class="InnerHeading">
            Lãi tạm tính
        </th>
    </tr>
    <%for (int i = 0; i < personal.AssignAccounts[x].Holding.Count; i++)
      { %>
    <tr>
        <td class="InnerData">
            <div style="font-weight: bold;" title="<%=personal.AssignAccounts[x].Holding[i].Quotes.CompanyName%>">
                <%=personal.AssignAccounts[x].Holding[i].Quotes.Symbol%></div>
        </td>
        <td class="InnerData">
            <%=personal.AssignAccounts[x].Holding[i].Account.tradingAmount.ToString("N0")%>
        </td>
        <td class="InnerData">
            <%=personal.AssignAccounts[x].Holding[i].Account.nettingAmount.ToString("N0")%>
        </td>
        <td class="InnerData">
            <%=personal.AssignAccounts[x].Holding[i].Account.lockedAmount.ToString("N0")%>
        </td>
        <td class="InnerData">
            <%=personal.AssignAccounts[x].Holding[i].Account.trustedAmount.ToString("N0")%>
        </td>
        <td class="InnerData" style="text-align: right">
            <%=personal.AssignAccounts[x].Holding[i].AverageBought.ToString("N")%>
        </td>
        <td class="InnerData">
            <%=personal.AssignAccounts[x].Holding[i].Quotes.Closed %>
        </td>
        <td class="InnerData">
            <%=((personal.AssignAccounts[x].Holding[i].Quotes.Closed - personal.AssignAccounts[x].Holding[i].AverageBought) < 0) ? 
                "<span style=\"color: red;\">" + String.Format("{0:n}", personal.AssignAccounts[x].Holding[i].Quotes.Closed - personal.AssignAccounts[x].Holding[i].AverageBought) + "▼" + String.Format("{0:n}", (personal.AssignAccounts[x].Holding[i].Quotes.Closed - personal.AssignAccounts[x].Holding[i].AverageBought) * 100 / (personal.AssignAccounts[x].Holding[i].Quotes.Closed+1)) + "%</span>" : 
                "<span style=\"color: green;\">" + String.Format("{0:n}", personal.AssignAccounts[x].Holding[i].Quotes.Closed - personal.AssignAccounts[x].Holding[i].AverageBought) + "▲" + String.Format("{0:n}", (personal.AssignAccounts[x].Holding[i].Quotes.Closed - personal.AssignAccounts[x].Holding[i].AverageBought) * 100 / (personal.AssignAccounts[x].Holding[i].Quotes.Closed+1)) + "%</span>" %>
        </td>
        <td class="InnerData" style="text-align: right">
            <%=((personal.AssignAccounts[x].Holding[i].Quotes.Closed - personal.AssignAccounts[x].Holding[i].AverageBought) < 0) ? 
                            "<span style=\"color: red;\">" + String.Format("{0:0,0}", (personal.AssignAccounts[x].Holding[i].Quotes.Closed - personal.AssignAccounts[x].Holding[i].AverageBought) * (personal.AssignAccounts[x].Holding[i].Account.tradingAmount + personal.AssignAccounts[x].Holding[i].Account.nettingAmount)*1000) + "</span>" : 
                            "<span style=\"color: green;\">" + String.Format("{0:0,0}", (personal.AssignAccounts[x].Holding[i].Quotes.Closed - personal.AssignAccounts[x].Holding[i].AverageBought) * (personal.AssignAccounts[x].Holding[i].Account.tradingAmount + personal.AssignAccounts[x].Holding[i].Account.nettingAmount)*1000) + "</span>"%>
        </td>
    </tr>
    <%}%>
    <tr>
        <th class="InnerData">
            Giá trị:
        </th>
        <th class="InnerData">
            <%=String.Format("{0:0,0}", personal.AssignAccounts[x].TradingValue)%>
        </th>
        <th class="InnerData">
            <%=String.Format("{0:0,0}", personal.AssignAccounts[x].NettingValue)%>
        </th>
        <th class="InnerData">
            <%=String.Format("{0:0,0}", personal.AssignAccounts[x].LockedValue)%>
        </th>
        <th class="InnerData">
            &nbsp;
        </th>
        <th class="InnerData" colspan="2">
            Tổng giá trị:
            <%=(personal.AssignAccounts[x].TotalValue + personal.AssignAccounts[x].NettingValue < 0) ? "<span style=\"color: red;\">" + String.Format("{0:0,0}", (personal.AssignAccounts[x].TotalValue + personal.AssignAccounts[x].NettingValue) / 1000) + "</span>" : "<span style=\"color: green;\">" + String.Format("{0:0,0}", (personal.AssignAccounts[x].TotalValue + personal.AssignAccounts[x].NettingValue) / 1000) + "</span>"%>
        </th>
        <th class="InnerData" colspan="2">
        </th>
    </tr>
    <%}%>
</table>
<%} %>
<br />
